﻿using System;

namespace HalconDotNet
{
	// Token: 0x02000094 RID: 148
	internal class HTupleElementsHandle : HTupleElementsImplementation
	{
		// Token: 0x06001F0A RID: 7946 RVA: 0x000B8273 File Offset: 0x000B6473
		internal HTupleElementsHandle(HTupleHandle source, int index) : base(source, index)
		{
		}

		// Token: 0x06001F0B RID: 7947 RVA: 0x000B827D File Offset: 0x000B647D
		internal HTupleElementsHandle(HTupleHandle source, int[] indices) : base(source, indices)
		{
		}

		// Token: 0x06001F0C RID: 7948 RVA: 0x000B8858 File Offset: 0x000B6A58
		public override HHandle[] getH()
		{
			if (this.indices == null)
			{
				return null;
			}
			HHandle[] array = new HHandle[this.indices.Length];
			for (int i = 0; i < this.indices.Length; i++)
			{
				array[i] = this.source.HArr[this.indices[i]];
			}
			return array;
		}

		// Token: 0x06001F0D RID: 7949 RVA: 0x000B88A8 File Offset: 0x000B6AA8
		public override int[] getI()
		{
			if (this.indices == null)
			{
				return null;
			}
			int[] array = new int[this.indices.Length];
			for (int i = 0; i < this.indices.Length; i++)
			{
				if (!HalconAPI.IsLegacyHandleMode())
				{
					throw new HTupleAccessException("Implicit access to handle as number is only allowed in legacy handle mode. Use *.H.Handle to get IntPtr value.");
				}
				if (HalconAPI.isPlatform64)
				{
					throw new HTupleAccessException("System.Int32 cannot represent a handle on this platform");
				}
				array[i] = (int)this.source.HArr[this.indices[i]].Handle;
				this.source.HArr[this.indices[i]].Detach();
			}
			return array;
		}

		// Token: 0x06001F0E RID: 7950 RVA: 0x000B8940 File Offset: 0x000B6B40
		public override long[] getL()
		{
			if (this.indices == null)
			{
				return null;
			}
			long[] array = new long[this.indices.Length];
			for (int i = 0; i < this.indices.Length; i++)
			{
				if (!HalconAPI.IsLegacyHandleMode())
				{
					throw new HTupleAccessException("Implicit access to handle as number is only allowed in legacy handle mode. Use *.H.Handle to get IntPtr value.");
				}
				array[i] = (long)this.source.HArr[this.indices[i]].Handle;
				this.source.HArr[this.indices[i]].Detach();
			}
			return array;
		}

		// Token: 0x06001F0F RID: 7951 RVA: 0x000B89C8 File Offset: 0x000B6BC8
		public override void setH(HHandle[] h)
		{
			if (!base.IsValidArrayForSetX(h))
			{
				return;
			}
			bool flag = h.Length == 1;
			for (int i = 0; i < this.indices.Length; i++)
			{
				if (this.source.HArr[this.indices[i]] != null)
				{
					this.source.HArr[this.indices[i]].Dispose();
				}
				this.source.HArr[this.indices[i]] = new HHandle(h[flag ? 0 : i]);
			}
		}

		// Token: 0x06001F10 RID: 7952 RVA: 0x000B8A4C File Offset: 0x000B6C4C
		public override object[] getO()
		{
			if (this.indices == null)
			{
				return null;
			}
			object[] array = new object[this.indices.Length];
			for (int i = 0; i < this.indices.Length; i++)
			{
				array[i] = this.source.HArr[this.indices[i]];
			}
			return array;
		}

		// Token: 0x06001F11 RID: 7953 RVA: 0x000B8A9C File Offset: 0x000B6C9C
		public override HTupleType getType()
		{
			return HTupleType.HANDLE;
		}
	}
}
